1. Technical Field
This invention generally relates to object oriented programming and more specifically relates to a mechanism and method for supporting class casting of run-time extensible items in an object oriented framework.
2. Background Art
The development of the EDVAC computer system of 1948 is often cited as the beginning of the computer era. Since that time, computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs. As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer systems typically include operating system software that controls the basic function of the computer, and one or more software application programs that run under the control of the operating system to perform desired tasks. For example, a typical IBM Personal Computer may run the OS/2 operating system, and under the control of the OS/2 operating system, a user may execute an application program, such as a word processor. As the capabilities of computer systems have increased, the application software programs designed for high performance computer systems have become extremely powerful. Additionally, software development costs have continued to rise because more powerful and complex programs take more time, and hence more money, to produce.
One way in which the performance of application software programs has been improved while the associated development costs have been reduced is by using object oriented programming concepts. The goal of using object oriented programming is to create small, reusable sections of program code known as xe2x80x9cobjectsxe2x80x9d that can be quickly and easily combined and re-used to create new programs. This is similar to the idea of using the same set of building blocks again and again to create many different structures. The modular and re-usable aspects of objects will typically speed development of new programs, thereby reducing the costs associated with the development cycle. In addition, by creating and re-using a comprehensive set of well-tested objects, a more stable, uniform, and consistent approach to developing new computer programs can be achieved.
A central concept in object oriented programming is the xe2x80x9cclass.xe2x80x9d A class is a template that defines a type of object. A class outlines or describes the characteristics or makeup of objects that belong to that class. By defining a class, objects can be created that belong to the class without having to rewrite the entire definition for each new object. This feature of object oriented programming promotes the reusability of existing object definitions and promotes more efficient use of program code.
Frameworks are relatively recent developments in object oriented programming that provide a group of pre-packaged classes and class relationships that are designed to help a user easily extend the framework to write a particular software program, such as a software application. One framework that is commercially available from IBM is known as San Francisco, which provides pre-defined classes that allow a user to easily extend the framework to define a custom software application, such as a general ledger or an order processing system. San Francisco defines a special type of domain-neutral object mechanism referred to herein as an extensible item. An extensible item can be dynamically reconfigured at run-time by adding or deleting domain-specific extensions to the extensible item object. An extensible item that holds a particular primary extension logically becomes an object of the type defined by the primary extension, thereby becoming domain-specific. In this manner the extensible item, which is domain-neutral, can acquire domain-specific extensions that define behavior that allows the extensible item to function as though it were domain-specific itself, although access to this function without the casting support described herein is through generic means.
Many object oriented programming languages, such as C++ and Java, provide type casting support. Type casting of classes allows a concrete subclass to inherit from more than one parent class, and if an instance of the subclass only needs to support one of the parent classes at run-time, the object can be xe2x80x9ccast toxe2x80x9d the desired parent class, thereby making the instance support only the desired parent class. The concept of class casting in a traditional object oriented programming environment, where classes statically inherit from each other at compile-time, is well known to one skilled in the art. However, there is currently no known way to provide class casting support for run-time extensible items, such as those defined by IBM""s San Francisco framework. Casting allows access to domain function in a domain-specific manner. Without a way to make run-time extensible items support class casting, the powerful concept of casting will be unavailable for run-time extensible items.
In an object oriented computer system, a framework mechanism defines one or more run-time extensible items that may be dynamically reconfigured as required to support different interfaces at run-time. The behavior associated with these interfaces is supported by one or more extensions owned by the extensible item. Each extensible item has one or more adapters that correspond to the extensions owned by the extensible item. The extensible item class defines a castTo( ) method. The castTo( ) method is invoked to logically cast an instance of the extensible item class to a desired class so that a selected method on that class can be called explicitly rather than by directly invoking the method provided by the extensible item. When the castTo( ) method is invoked on an instance of the extensible item class, the extensible item object determines if any of its extensions have an adapter that supports the class specified in the castTo( ) method call. If an adapter does support the specified class, the adapter corresponding is returned, and the selected method can then be invoked on the adapter. In this manner, class casting of run-time extensible items is achieved.
The foregoing and other features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings.